﻿
@{
    Layout = "~/Views/Shared/_LayoutForChild.cshtml";
}
@*@model IEnumerable<WebMobile.Models.Product>*@
@using PagedList.Mvc;
@model PagedList.IPagedList<WebMobile.Models.Product>

@{
    ViewBag.Title = "Index";
}
<link href="~/Content/PagedList.css" rel="stylesheet" />
<h2>Index</h2>

<p>
     @*@Html.ActionLink("Create New", "Create")*@
    <input type="button" value="Create New" style="width:100px" class="btn btn-info" onclick="location.href='@Url.Action("Create","Product")'" />
</p>

<div class="data" style="width:100%; height:100%">
<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.FirstOrDefault().ProductID)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FirstOrDefault().ProductNumber)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FirstOrDefault().Color)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FirstOrDefault().StandardCost)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FirstOrDefault().ListPrice)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FirstOrDefault().Size)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FirstOrDefault().Weight)
        </th>
        @*<th>
            @Html.DisplayNameFor(model => model.FirstOrDefault().SellStartDate)
        </th>*@
        <th>
            @Html.DisplayNameFor(model => model.FirstOrDefault().SellEndDate)
        </th>
        @*<th>
            @Html.DisplayNameFor(model => model.FirstOrDefault().DiscontinuedDate)
        </th>*@
        <th>
            @Html.DisplayNameFor(model => model.FirstOrDefault().ThumbNailPhoto)
        </th>
        @*<th>
            @Html.DisplayNameFor(model => model.ThumbnailPhotoFileName)
        </th>*@
        @*<th>
            @Html.DisplayNameFor(model => model.FirstOrDefault().rowguid)
        </th>*@
        <th>
            @Html.DisplayNameFor(model => model.FirstOrDefault().ModifiedDate)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FirstOrDefault().ProductCategory.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FirstOrDefault().ProductModel.Name)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.ProductNumber)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Color)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.StandardCost)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.ListPrice)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Size)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Weight)
        </td>
        @*<td>
            @Html.DisplayFor(modelItem => item.SellStartDate)
        </td>*@
        @*<td>
            @Html.DisplayFor(modelItem => item.SellEndDate)
        </td>*@
        @*<td>
            @Html.DisplayFor(modelItem => item.DiscontinuedDate)
        </td>*@
        @*<td>
            @Html.DisplayFor(modelItem => item.ThumbNailPhoto)
        </td>*@
        <td>

            @*@Html.DisplayFor(modelItem => item.ThumbnailPhotoFileName)*@
            @*@Html.ActionLink("Details", "Details", new { id = item.ProductID }, new { })*@
            <a href="@Url.Action("Details","Product", new { id=item.ProductID})">
                <img src="@item.PhotoString"  style="height:100px; width:100px"/>
            </a>
        </td>
        @*<td>
            @Html.DisplayFor(modelItem => item.rowguid)
        </td>*@
        <td>
            @Html.DisplayFor(modelItem => item.ModifiedDate)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.ProductCategory.Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.ProductModel.Name)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.ProductID }) |
            @Html.ActionLink("Details", "Details", new { id=item.ProductID }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.ProductID })
        </td>
    </tr>
}

</table>
<select disabled="disabled">
    <option value="5" selected ="selected">5</option>
    <option value="10">10</option>
    <option value="15">15</option>
    <option value="10">20</option>
</select>
Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount

@Html.PagedListPager(Model, page => Url.Action("Index", new { page , pageSize = 5}))
</div>